package cn.changeforyou.web.cloud.auth.entity;

import cn.changeforyou.web.cloud.webBase.model.BaseEntity;
import cn.changeforyou.web.cloud.rpc.service.auth.enums.OpenLevel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * 角色权限表, 超级管理员不在详情内
 * @TableName source_info
 */
@TableName(value ="source_info")
@Data
public class SourceInfo extends BaseEntity implements Serializable {
    /**
     * 
     */
    private Integer serviceId;

    /**
     * 1: 接口类型, 2:静态资源类型, 3:前端路由类型
     */
    private Integer resourceType;

    /**
     * 
     */
    private String value;

    /**
     * 完全开放(不需要认证):1, 不完全开放(认证即可用):2, 完全控制:3, 角色控制:4, 组织控制:5
     */
    private OpenLevel openLevel;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        SourceInfo that = (SourceInfo) o;
        if (!Objects.equals(serviceId, that.serviceId)) return false;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (serviceId != null ? serviceId.hashCode() : 0);
        result = 31 * result + (value != null ? value.hashCode() : 0);
        return result;
    }
}